<?php require_once('Connections/cnn.php'); ?>
<?php 
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
if (!isset($_SESSION)) {
  session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['email'])) {
  $loginUsername=$_POST['email'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "Rol";
  $MM_redirectLoginSuccess = "index _r.php";
  $MM_redirectLoginFailed = "error.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_cnn, $cnn);
    
  $LoginRS__query=sprintf("SELECT Email, Password, Rol FROM usuario WHERE Email=%s AND Password=%s",
  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
   
  $LoginRS = mysql_query($LoginRS__query, $cnn) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
    
    $loginStrGroup  = mysql_result($LoginRS,0,'Rol');
    
  if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;       

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];  
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}

?>

<!doctype html>
<html><!-- InstanceBegin template="/Templates/plantilla.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Ventas</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
<link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css">

<!-- InstanceEndEditable -->
<link href="css/estilo.css" rel="stylesheet" type="text/css">
 <link rel="stylesheet" href="css/jquery-ui.css" />
        <link rel="stylesheet" href="css/style.css" />
         <link href="css/styles.css" type="text/css" media="all" rel="stylesheet" />

<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<!-- InstanceBeginEditable name="1" -->
<!-- Skitter JS -->
  <script type="text/javascript" language="javascript" src="js/jquery-1.6.3.min.js"></script>
  <script type="text/javascript" language="javascript" src="js/menu.js"></script>
  <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
  <script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
      <script src="JSLogin/login.js"></script>
     <script src="JSLogin/jquery-ui.js"></script>

   


<![endif]-->


<!-- InstanceEndEditable -->

</head>


<body> 


<div class="container">
  <header>
    <img src="images/banner.png" width="960" height="194" />

     <div id="loginContainer">
              <a href="#" id="loginButton"><span>Login</span><em></em></a>
              <a href="registrarse.php" id="loginButton"><span>Registrarse</span><em></em></a>
                         <div id="loginBox">                
                       <form ACTION="<?php echo $loginFormAction; ?>" METHOD="POST" id="loginForm">
                        <fieldset id="body">
                            <fieldset>
                                <label for="email">Email</label>
                                <input type="text" name="email" id="email" />
                            </fieldset>
                            <fieldset>
                                <label for="password">Contraseña</label>
                                <input type="password" name="password" id="password" />
                            </fieldset>

                            <input type="submit" id="login" value="Iniciar Sesión" />
                            
                        </fieldset>
                        
                        </form>
                     </div>
          </div>
 
  </header>
   <ul class="menu">
            <li><a href="index.php">Home</a></li>
            <li><a href="Productos.php">Productos</a></li>
            <li><a href="#">Acerca</a></li>
            <li><a href="#">Contactanos</a></li>
        </ul>
 
   <br><br>


  <!-- InstanceBeginEditable name="2" -->
    <script type="text/javascript">
            $(document).ready(function() {
                $('.menu').tagdrop({tagPaddingTop: '60px',bgColor: '#B1CCED',bgMoverColor: '#7FB0F0',textColor: '#e0e0e0'});
            });
        </script>
  <table width="20%" border="0" id="numeros7">
    <tr>
      <td>
        <form id="formulario" name="formulario" method="post" action="enviar-mail.php" enctype="application/x-www-form-urlencoded">
        <table width="20%" border="0" id="sidebar3">
        <tr>
          <td><p>Nombre: </p>
            <p>
              <label for="nombre"></label>
              <span id="sprytextfield1">
              <input type="text" name="nombre" id="nombre">
              <span class="textfieldRequiredMsg">*</span></span></p></td>
          </tr>
        <tr>
          <td><p>Ingrese su Correo: </p>
            <p>
              <label for="correo"></label>
              <span id="sprytextfield2">
              <input type="text" name="correo" id="correo">
              <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">Formato no válido.</span></span></p></td>
          </tr>
        <tr>
          <td><p>Asunto:</p>
            <p><select name="asunto"><option value="comentario">Comentario</option><option value="pregunta">Pregunta</option><option value="sugerencia">Sugerencia</option></select></p></td>
          </tr>
        <tr>
          <td><p>Mensaje: </p>
            <p>
              <label for="mensaje"></label>
              <span id="sprytextarea1">
              <textarea name="mensaje" id="mensaje"></textarea>
              <span class="textareaRequiredMsg">*</span></span></p></td>
          </tr>
        <tr>
          <td><P><input type="submit" name="Enviar" id="Enviar" value="Enviar"></P>
   <?php
              error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
            if(isset($_GET['respuesta'])){
            echo"<span>".$_GET['respuesta']."</span>";
            }

           ?>   
          </td>
        
          </tr>
  </table>
  </form>
  </td>
    </tr>
</table>
 
 
 
  <script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email");
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1");
  </script>
  
  
    <div id="sidebar6">
      <center><h1>Contactanos</h1></center>
     <p>Visitanos en nuestras tiendas te atenderemos al instante.</p>
     <p>Dirección: .</p>
     <p>Telefonos: 2247-8732  2247-9054</p><br>
     <p>Mapa de Ubicación</p>
     <center><br><br><iframe width="470" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com.sv/maps?ie=UTF8&amp;q=TADROS&amp;fb=1&amp;gl=sv&amp;hq=tadros&amp;hnear=0x8f633067b411775d:0x1f75978893fb5c96,San+Salvador&amp;cid=0,0,11713729818612317055&amp;t=m&amp;ll=13.716213,-89.246144&amp;spn=0.006295,0.006295&amp;output=embed"></iframe><br /><small><a href="https://maps.google.com.sv/maps?ie=UTF8&amp;q=TADROS&amp;fb=1&amp;gl=sv&amp;hq=tadros&amp;hnear=0x8f633067b411775d:0x1f75978893fb5c96,San+Salvador&amp;cid=0,0,11713729818612317055&amp;t=m&amp;ll=13.716213,-89.246144&amp;spn=0.006295,0.006295&amp;source=embed" style="color:#0000FF;text-align:left">Ver mapa más grande</a></small></center>
    </div>
    
  <!-- InstanceEndEditable -->

  <footer>
    <h3>Super Gangas</h3>
  </footer>
  <!-- end .container --></div>
</body>
<!-- InstanceEnd --></html>